<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <!--edge浏览器H5兼容设置-->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!--360浏览器H5兼容设置-->
    <meta name="renderer" content="webkit" />
    <title>电脑商城</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!--导入核心文件-->
    <script src="/computershop/static/web/bootstrap3/js/holder.js"></script>
    <link href="/computershop/static/web/bootstrap3/css/bootstrap.css" rel="stylesheet" type="text/css">
    <script src="/computershop/static/web/bootstrap3/jquery-1.9.1.min.js"></script>
    <script src="/computershop/static/web/bootstrap3/js/bootstrap.js"></script>
    <!-- 字体图标 -->
    <link rel="stylesheet" href="/computershop/static/web/bootstrap3/font-awesome-4.7.0/css/font-awesome.css" />
    <link rel="stylesheet" type="text/css" href="/computershop/static/web/css/layout.css" />
    <link rel="stylesheet" type="text/css" href="/computershop/static/web/css/top.css" />
    <link rel="stylesheet" type="text/css" href="/computershop/static/web/css/footer.css" />
    <link rel="stylesheet" type="text/css" href="/computershop/static/web/css/orderConfirm.css" />
    <link rel="stylesheet" type="text/css" href="/computershop/static/web/css/cart.css" />
    <script src="/computershop/static/web/js/orderConfirm.js" type="text/javascript" charset="utf-8"></script>
</head>

<body>
<!--头部-->
<jsp:include page="/WEB-INF/web/inc/header.jsp"></jsp:include>
<!--头部结束-->
<!--导航结束-->
<div class="container">
    <div class="col-md-offset-1 col-md-10">
        <div class="col-md-4">
            <div class="col-md-12 torder-bar-active">
                1.确认订单信息
                <span class="pull-right"><span class="fa fa-chevron-right"></span></span>
            </div>
        </div>
        <div class="col-md-4">
            <div class="col-md-12 torder-bar-undo">
                2.在线支付
                <span class="pull-right"><span class="fa fa-chevron-right"></span></span>
            </div>
        </div>
        <div class="col-md-4">
            <div class="col-md-12 torder-bar-undo">
                3.付款成功
            </div>
        </div>
        <div class="col-md-12">
            <form id="form-create-torder" role="form" action="/computershop/web/addOrder">
                <div class="form-group">
                    <label for="name">
                        <p>选择收货地址：</p>
                    </label>
                    <select name="aid" id="address-list" class="form-control">
                        <option value="${requestScope.orderConfirmDefaultAddress.id}">${requestScope.orderConfirmDefaultAddress.name}&nbsp;&nbsp;&nbsp;${requestScope.orderConfirmDefaultAddress.tag}&nbsp;&nbsp;&nbsp;${requestScope.orderConfirmDefaultAddress.provinceName}${requestScope.orderConfirmDefaultAddress.cityName}${requestScope.orderConfirmDefaultAddress.areaName}${requestScope.orderConfirmDefaultAddress.detail}&nbsp;&nbsp;&nbsp;${requestScope.orderConfirmDefaultAddress.phone}</option>
                        <c:forEach items="${requestScope.orderConfirmAddressList}" var="address">
                            <option value="${address.id}">${address.name}&nbsp;&nbsp;&nbsp;${address.tag}&nbsp;&nbsp;&nbsp;${address.provinceName}${address.cityName}${address.areaName}${address.detail}&nbsp;&nbsp;&nbsp;${address.phone}</option>
                        </c:forEach>
                    </select>
                </div>
                <div class="panel panel-primary">
                    <div class="panel-heading">
                        <p class="panel-title">订单商品信息：</p>
                    </div>
                    <div class="panel-body">
                        <table class="cart-table" width="100%">
                            <thead>
                            <tr>
                                <th width="15%"></th>
                                <th width="35%">商品</th>
                                <th width="15%">单价</th>
                                <th width="15%">数量</th>
                                <th width="20%">金额</th>
                            </tr>
                            </thead>
                            <tbody id="cart-list" class="cart-body">
                            <c:forEach items="${requestScope.checkedCartList}" var="cart">
                                <tr>
                                    <input type="hidden" name="cartProductId" value="${cart.product.id}">
                                    <input type="hidden" name="cartBuyNum" value="${cart.num}">
                                    <td><img src="/computershop/static/web${cart.product.image}collect.png" class="img-responsive" /></td>
                                    <td>${cart.product.title}</td>
                                    <td>¥<span>${cart.price}</span></td>
                                    <td class="cart_num">${cart.num}</td>
                                    <td class="cart_subtotle">${cart.price*cart.num}</td>
                                </tr>
                            </c:forEach>
                            </tbody>
                        </table>
                        <div class="total-bar">
                            &nbsp;
                            <span class="pull-right">已选商品
										<span id="all-count" style="font-size: larger; color: red;font-weight: bold">1</span>件 总价¥
										<span id="all-price"  style="font-size: larger; color: red;font-weight: bold">5298</span>元

									</span>
                        </div>
                    </div>
                </div>
                <div class="pay-bar">
                    <a href="/computershop/web/cart">返回购物车</a>
                    <input id="btn-create-torder" type="submit"  style="margin-left: 700px;height: 40px;background-color: #2aabd2;width: 80px;color: white;font-weight: bold" value="在线支付" />
                </div>
            </form>
        </div>
    </div>
</div>
<!--页脚开始-->
<jsp:include page="/WEB-INF/web/inc/foot.jsp"></jsp:include>
<!--页脚结束-->
</body>

</html>
<script>
    $(function (){
        cauculate();
    });
    function cauculate(){
        var allCount = 0;
        var allPrice = 0;
        var nums = $(".cart_num");
        for (var i=0;i<nums.length;i++)
        {
            allCount += parseInt(nums.eq(i).text());
        }
        $("#all-count").html(allCount);
        var prices = $(".cart_subtotle");
        for(var i=0;i<prices.length;i++)
        {
            allPrice += parseInt(prices.eq(i).text());
        }
        $("#all-price").html(allPrice);
    }
</script>